﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewRen.Models.ViewModel
{
    public class vUserGroup
    {
        public int ID { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>

        public string LoginName { get; set; }


        /// <summary>
        /// 密码
        /// </summary>
        public string LoginPassword { get; set; }


        /// <summary>
        /// 真是姓名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 自我描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 邮件
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// QQ
        /// </summary>
        public string QQ { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public Sex Sex { set; get; }

        /// <summary>
        /// 出生年月日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 积分
        /// </summary>
        public int? Integration { get; set; }

        /// <summary>
        /// 金钱
        /// </summary>
        public double Money { get; set; }


        /// <summary>
        /// 微博
        /// </summary>
        public string Weibo { get; set; }

        /// <summary>
        /// 微信
        /// </summary>
        public string WhatApp { get; set; }


        /// <summary>
        /// 牛棚名称
        /// </summary>
        public string GroupName { get; set; }

        /// <summary>
        /// 上次登录时间
        /// </summary>
        public DateTime? LastLogin { get; set; }

        /// <summary>
        /// 优先级 用于排名
        /// </summary>
        public int Priority { get; set; }

        /// <summary>
        /// 牛棚，可空
        /// </summary>
        public int? UserGroupID { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        public byte[] Picture { get; set; }

        /// <summary>
        /// 访问量
        /// </summary>
        public int PV { get; set; }

        /// <summary>
        /// 今日访问量
        /// </summary>
        public int TodayPV { get; set; }

        /// <summary>
        ///赞
        /// </summary>
        public int Ups { get; set; }

        /// <summary>
        /// 踩
        /// </summary>
        public int Downs { get; set; }
        /// /// <summary>
        /// 增加时间
        /// </summary>
        public DateTime? AddTime { get; set; }

        /// <summary>
        /// 行业
        /// </summary>
        public string Industry { get; set; }

        /// <summary>
        /// 图片
        /// </summary>
        public List<Images> Images { get; set; }

        /// <summary>
        /// 是否认证
        /// </summary>
        public bool IsVerified { set; get; }

        public vUserGroup() { }

        public vUserGroup(UserGroup group)
        {
            DB db = new DB();
            this.ID = group.ID;
            this.GroupName = group.GroupName;
            this.LoginName = group.LoginName;
            this.LoginPassword = group.LoginPassword;
            this.Email = group.Email;
            this.Phone = group.Phone;
            this.Address = group.Address;
            this.AddTime = group.AddTime;
            this.Weibo = group.Weibo;
            this.WhatApp = group.WhatApp;
            this.Description = group.Description;
            this.LastLogin = group.LastLoginTime;
            this.City = group.City;
            this.Picture = group.Picture;
            this.Priority = group.Priority;
            this.Industry = group.Industry;
            this.TodayPV = group.TodayPV;
            this.PV = group.PV;
            this.Downs = group.Downs;
            this.Ups = group.Ups;
            this.Images = db.Images.Where(c => c.TID == group.ID).Where(c => c.ImageType == ImageType.UserGroup).ToList();
            this.IsVerified = group.IsVerified;
        }
    }
}
